﻿<div class="editor-label">
<input type="checkbox" id="isChecked1" @((DateTime)Model != DateTime.MinValue?"checked='checked'":"") onchange="dehospChange(this);return false;"/>
出院
</div>
<span class="small-input">
@if ((DateTime)Model == DateTime.MinValue)
{
    var g = "dehostpTime1";
    <div class="editor-field" id="DeHospDay" style="display:none">            
        @Html.TextBox("",
                    string.Format("{0:yyyy-MM-dd}", DateTime.MinValue),
        new { id = g })           
        <script type="text/javascript">            $(function () { $('#@(g)').datepicker(); });</script>        
        @Html.ValidationMessageFor(model => model)
    </div>
}
else
{
    var g = "dehostpTime1";
    <div class="editor-field" id="DeHospDay">
        @Html.TextBox("",
        string.Format("{0:yyyy-MM-dd}", (DateTime)Model.Date),
                new { id = g })   
        <script type="text/javascript">                $(function () { $('#@(g)').datepicker(); });</script>    
         @Html.ValidationMessageFor(model => model)
    </div>     
}
</span>
<script type="text/javascript">
    function dehospChange(obj) {
        if ($(obj).prop("checked")) {
            $("#DeHospDay").show();
            if ($("#dehostpTime1").val()=="0001-01-01") {
                var today = new Date();

                $("#dehostpTime1").val(today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate());
            }
        }
        else {
            $("#DeHospDay").hide();

            $("#dehostpTime1").val("0001-01-01");
        }
    }
</script>